package oo

import (
	"fmt"
)

type Worker interface {
	work()
	sing()
}

//结构体嵌套接口就可以直接调用接口中的方法,相当于实现了该接口
type Employee struct {
	name string
	Worker
}



type student struct{
	name string
}

func (s student) work() {
	fmt.Println("I am ", s.name, ", I am learning")
}

func (s student) sing() {
	fmt.Println("student sing!")
}

//Employee2选择性实现接口Worker中方法,用哪个实现哪个
type Employee2 struct {
	name string
	Worker
}

func (e2 Employee2) work()  {
	fmt.Println("Employee2 learning")
}



func RunInnerFace() {
	var w Worker = Employee{Worker: student{"polarisxu"}}
	w.work()

	var w2 Worker = Employee2{}
	w2.work()

}
